package com.suian.spring.aop.interceptor;

import com.suian.spring.aop.MethodInterceptor;
import com.suian.spring.aop.MethodInvocation;

public class PerformanceInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        long start = System.currentTimeMillis();
        try {
            return invocation.proceed();
        } finally {
            long elapsed = System.currentTimeMillis() - start;
            System.out.println("[Perf] Method " + invocation.getMethod().getName()
                    + " took " + elapsed + "ms");
        }
    }
}
